// 任务来源类型
export const TASK_SOURCE_OPTIONS = [
  {
    label: "页面",
    value: "01"
  },
  {
    label: "接口",
    value: "02"
  },
  {
    label: "后台",
    value: "03"
  }
];
// 任务类型
export const TASK_OPTIONS = [
  {
    label: "终端上传",
    value: "01"
  },
  {
    label: "主站采集",
    value: "02"
  }
];

export const TABLE_COLUMNS = [
  {
    title: "序号",
    type: "index",
    key: "id",
    width: 65,
    align: "center"
  },
  {
    title: "采集对象",
    key: "devName"
  },
  {
    title: "任务来源",
    key: "nextTaskSource"
  },
  {
    title: "任务类型",
    key: "nextTaskType"
  },
  {
    title: "优先级",
    key: "setLevel"
  },
  {
    title: "设置时间",
    key: "setTime"
  },
  {
    title: "维护人",
    key: "userName"
  }
].map((element) => {
  const { width } = element;
  if (!width) {
    return {
      ...element,
      minWidth: 200
    };
  }
  return element;
});

export const RULES_SEARCH = {
  custId: [
    {
      required: true,
      message: "请选择客户名称",
      trigger: "change"
    }
  ],
  devid: [
    {
      required: true,
      message: "请选择采集对象",
      trigger: "change"
    }
  ]
};

export const RULES_EDIT = {
  custId: [
    {
      required: true,
      message: "请选择客户名称",
      trigger: "change"
    }
  ],
  devid: [
    {
      required: true,
      message: "请选择采集对象",
      trigger: "change"
    }
  ],
  taskSource: [
    {
      required: true,
      message: "请选择任务来源",
      trigger: "change"
    }
  ],
  taskType: [
    {
      required: true,
      message: "请选择任务类型",
      trigger: "change"
    }
  ],
  setLevel: [
    {
      type: "number",
      required: true,
      message: "请输入优先级",
      trigger: "change"
    },
    {
      validator: (rule, value, callback) => {
        if (!Number.isInteger(value)) {
          callback(new Error("请输入整数值"));
        }
        callback();
      },
      trigger: "change"
    }
  ]
};
